import React, { Component } from 'react';

class Cmp1 extends Component {
  constructor(...args){
      super(...args);
      this.state={
          a:1,
          users:[]
      }
      this.data=[];
  }
  async componentDidMount(){
      let res = await fetch('/data/1.json');
      let data = await res.json();
      this.setState({
          users:data
      })
      console.log(this.data)
  }

  fn(){
      this.setState({
          a:this.state.a+1
      })
  }


  render() {
    return (
      <div>
          <input type="button" value="+1" onClick={this.fn.bind(this)}/>
          {this.state.a}
          {
              this.state.users.map((json,index)=>(
                  <div>{json.user},{json.age}</div>
              ))
          }
      </div>
    );
  }
}

export default Cmp1;
